<template>
  <div class="lllustration-container no-background-container">
    <el-row :gutter="20">
      <el-col>
        <vab-card>
          <el-form @submit.prevent>
            <el-form-item label="换肤" label-width="40">
              <vab-color-picker />
            </el-form-item>
            <el-form-item label="svg大小">
              <el-slider v-model="queryForm.num" :max="300" :min="150" style="width: 190px; margin: 0 20px 0 5px" />
              px
            </el-form-item>
          </el-form>
        </vab-card>
      </el-col>
      <el-col v-for="(item, index) in lllustrationsArray" :key="index" :lg="4" :md="12" :sm="12" :xl="4" :xs="24">
        <vab-card class="lllustration-card" @click="handleCopyIcon(item)">
          <vab-icon
            class="vab-lllustration"
            :icon="item"
            is-custom-svg
            :style="{
              width: queryForm.num + 'px',
              height: queryForm.num + 'px',
            }"
          />
        </vab-card>
      </el-col>
    </el-row>
  </div>
</template>

<script lang="ts" setup>
import clip from '/@/utils/clipboard'

const lllustrationsArray: string[] = []

const files: any = import.meta.glob('../../icon/lllustration/*.svg', {
  eager: true,
})

for (const key in files) {
  const _key = key.slice(11)
  lllustrationsArray.unshift(_key.substring(0, _key.length - 4))
}

const queryForm = reactive<any>({
  num: 150,
})

const handleCopyIcon = (item: any) => {
  clip(`<vab-icon style="width:100%;height:300px" icon="${item}" is-custom-svg/>`)
}
</script>

<style lang="scss" scoped>
.lllustration-container {
  .vab-lllustration {
    width: 100%;
    height: 100%;
    cursor: pointer;
  }

  :deep() {
    .el-form-item:last-child {
      margin-bottom: 0;
    }

    .vab-color-picker {
      margin-left: 0 !important;
    }

    .lllustration-card {
      display: flex;
      align-items: center;
      justify-content: center;
    }
  }
}
</style>
